package com.wiscamp.ninechapters.accounts.infrastructure.po;

import com.wiscamp.ninechapters.ddd.PersistenceObject;
import jakarta.persistence.*;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collection;

/**
 * 账户日志
 */
@Data
@jakarta.persistence.Entity
@Table(name = "account_log")
public class AccountLogPO implements PersistenceObject {
    private static final long serialVersionUID = 1L;
    @Transient
    private Collection<AccountBatchLogPO> accountLogBatches = new ArrayList<>();
    /**
     * 账户日志
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "log_id", insertable = false, nullable = false)
    private long logId = 0;
    /**
     * 账户编号
     */
    @Column(name = "account_id", nullable = false)
    private long accountId = 0;
    /**
     * 账户类型
     */
    @Column(name = "account_type", nullable = false)
    private int accountType = 0;
    /**
     * 用户编号
     */
    @Column(name = "user_id", nullable = false)
    private long userId = 0;
    /**
     * 是否批次管理
     */
    @Column(name = "batch_management", nullable = false)
    private boolean batchManagement = false;
    /**
     * 借贷类型
     */
    @Column(name = "debit_credit_type", nullable = false)
    private int debitCreditType = 0;
    /**
     * 期初余额
     */
    @Column(name = "beginning_balance", nullable = false)
    private BigDecimal beginningBalance = new BigDecimal(0);
    /**
     * 借方发生额
     */
    @Column(name = "debit_amount", nullable = false)
    private BigDecimal debitAmount = new BigDecimal(0);
    /**
     * 贷方发生额
     */
    @Column(name = "credit_amount", nullable = false)
    private BigDecimal creditAmount = new BigDecimal(0);
    /**
     * 期末余额
     */
    @Column(name = "closing_balance", nullable = false)
    private BigDecimal closingBalance = new BigDecimal(0);
    /**
     * 关联类型
     */
    @Column(name = "reference_type", nullable = false)
    private int referenceType = 0;
    /**
     * 关联编号
     */
    @Column(name = "reference_id", nullable = false)
    private long referenceId = 0;
    /**
     * 关联备注
     */
    @Column(name = "reference_remark", nullable = false)
    private String referenceRemark = "";
    /**
     * 创建时间
     */
    @Column(name = "created_time", nullable = false)
    private LocalDateTime createTime;
    /**
     * 变更时间
     */
    @Column(name = "modified_time", nullable = false)
    private LocalDateTime editTime;
    /**
     * 操作人
     */
    @Column(name = "operate_user", nullable = false)
    private long operateUser = 0;
    /**
     * 备注
     */
    @Column(name = "remark")
    private String remark = "";
}